package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ktgj.customer.domain.DepositRefundcash;
import com.ktgj.customer.service.IDepositRefundcashService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 预留款返现申请
Controller
 * 
 * @author ruoyi
 * @date 2021-07-27
 */
@ControllerAdvice
@RestController
@RequestMapping("/refundcash")
public class DepositRefundcashController extends BaseController
{
    @Autowired
    private IDepositRefundcashService depositRefundcashService;

    /**
     * 查询预留款返现申请
列表
     */
    @PreAuthorize(hasPermi = "system:refundcash:list")
    @GetMapping("/list")
    public TableDataInfo list(DepositRefundcash depositRefundcash)
    {
        startPage();
        List<DepositRefundcash> list = depositRefundcashService.selectDepositRefundcashList(depositRefundcash);
        return getDataTable(list);
    }

    /**
     * 导出预留款返现申请
列表
     */
    @PreAuthorize(hasPermi = "system:refundcash:export")
    @Log(title = "预留款返现申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DepositRefundcash depositRefundcash) throws IOException
    {
        List<DepositRefundcash> list = depositRefundcashService.selectDepositRefundcashList(depositRefundcash);
        ExcelUtil<DepositRefundcash> util = new ExcelUtil<DepositRefundcash>(DepositRefundcash.class);
        util.exportExcel(response, list, "预留款返现申请数据");
    }

    /**
     * 获取预留款返现申请
详细信息
     */
    @PreAuthorize(hasPermi = "system:refundcash:query")
    @GetMapping(value = "/{refundcashId}")
    public AjaxResult getInfo(@PathVariable("refundcashId") Long refundcashId)
    {
        return AjaxResult.success(depositRefundcashService.selectDepositRefundcashById(refundcashId));
    }

    /**
     * 新增预留款返现申请

     */
    @PreAuthorize(hasPermi = "system:refundcash:add")
    @Log(title = "预留款返现申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DepositRefundcash depositRefundcash)
    {
        return toAjax(depositRefundcashService.insertDepositRefundcash(depositRefundcash));
    }

    /**
     * 修改预留款返现申请

     */
    @PreAuthorize(hasPermi = "system:refundcash:edit")
    @Log(title = "预留款返现申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DepositRefundcash depositRefundcash)
    {
        return toAjax(depositRefundcashService.updateDepositRefundcash(depositRefundcash));
    }

    /**
     * 删除预留款返现申请

     */
    @PreAuthorize(hasPermi = "system:refundcash:remove")
    @Log(title = "预留款返现申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{refundcashIds}")
    public AjaxResult remove(@PathVariable Long[] refundcashIds)
    {
        return toAjax(depositRefundcashService.deleteDepositRefundcashByIds(refundcashIds));
    }
}
